package coreconcurrency.mem;

/**
 * create by yongli on 2022-04-19 09:34
 * 探索，什么时候，线程会刷新变量到主存，什么时候读取的副本有问题
 */

public class MultiThreadTest {

    int[] arr = {1212, 2132, 2332};
    Computer computerGlobal = new Computer(new Screen(1200, 1300), arr, "china");

    public static void main(String[] args) throws Exception {
        new MultiThreadTest().test();

    }

    public void test() {
        // 方法上的变量
        int[] arr2 = {1212, 2132, 2332};
        Computer computer = new Computer(new Screen(12, 12), arr2, "china");
        MultiThread multiThread = new MultiThread(computerGlobal, 10);
        MultiThread multiThread1 = new MultiThread(computerGlobal, 10000);

        // 启动线程，线程是如何切换的？
        multiThread.start();
        multiThread1.start();
    }
}
